package cn.tedu.review;
/**本类用于回顾继承*/
public class TestExtends {
    //7.创建子类对象进行测试
    public static void main(String[] args) {
       ComputerStudent s1=new ComputerStudent(1,"张三",'男',98);
       MathStudent s2=new MathStudent(2,"李四",'女',89);
       ChineseStudent s3=new ChineseStudent(3,"王五",'女',100);
       //8.利用创建好的对象进行方法测试
        s1.professionalClass();
        s1.hobby();
        s2.professionalClass();
        s2.hobby();
        s3.professionalClass();
        s3.hobby();
        //9.创建父类的对象方法进行方法测试
        Student s0=new Student(0,"海绵宝宝",'男',56);
        s0.thinkingClass();
        s0.professionalClass();
       
       
        
    }
}
//1.定义学生类
class Student{
    //2.定义学生属性
    int sno;
    String name;
    char gender;
    double score;
    //5.添加父类的全参构造

    public Student(int sno, String name, char gender, double score) {
        this.sno = sno;
        this.name = name;
        this.gender = gender;
        this.score = score;

    }

    //4.定义父类的功能
    public void thinkingClass(){
        System.out.println("正在上思修课");
    }
    public void professionalClass(){
        System.out.println("正在上专业课");
    }
}
//3.定义学生类的子类，区分不同专业
class ComputerStudent extends Student{
    public ComputerStudent(int sno, String name, char gender, double score) {
        super(sno, name, gender, score);
    }

    @Override
    public void professionalClass() {
        System.out.println("正在上编程课");
    }
    public void hobby(){
        System.out.println("喜欢敲代码~");

    }
}
class MathStudent extends Student{
    public MathStudent(int sno, String name, char gender, double score) {
        super(sno, name, gender, score);
    }

    @Override
    public void professionalClass() {
        System.out.println("正在上数学理论课");
    }
    public void hobby(){
        System.out.println("喜欢学模糊数学");

    }

}
class ChineseStudent extends Student{
    public ChineseStudent(int sno, String name, char gender, double score) {
        super(sno, name, gender, score);
    }

    @Override
    public void professionalClass() {
        System.out.println("正在上写作课");
    }
    public void hobby(){
        System.out.println("喜欢写小说");
    }

}